﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace AutoIt_Elements.Core
{
	public class ChecksumProvider
	{
		public static string File_SHA1(string FilePath)
		{
			if(File.Exists(FilePath))
			{
				byte[] sha1hash = null;
				using(FileStream FileCheck = System.IO.File.OpenRead(FilePath))
				{
					System.Security.Cryptography.SHA1 sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
					sha1hash = sha1.ComputeHash(FileCheck);
				}
				return BitConverter.ToString(sha1hash).Replace("-", "");
			}
			else
			{
				return null;
			}
		}

		public static string File_MD5(string FilePath)
		{
			if(File.Exists(FilePath))
			{
				byte[] md5Hash = null;
				using(FileStream FileCheck = System.IO.File.OpenRead(FilePath))
				{
					System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
					md5Hash = md5.ComputeHash(FileCheck);
				}
				return BitConverter.ToString(md5Hash).Replace("-", "");
			}
			else
			{
				return null;
			}
		}
	}
}
